package com.nbsaas.boot.pms.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;
import java.util.Date;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "任务", model = "任务")
@Entity
@Table(name = "bs_pms_task")
@Comment("任务表")
public class Task extends AbstractEntity {

    @Comment("任务名称")
    @SearchItem(name = "name", key = "name", label = "任务名称")
    @FormField(title = "任务名称", sortNum = "1", grid = true, required = true)
    @Column(length = 200, nullable = false)
    private String name;

    @Comment("任务编码")
    @SearchItem(name = "code", key = "code", label = "任务编码")
    @FormField(title = "任务编码", sortNum = "2", grid = true)
    @Column(length = 50, unique = true)
    private String code;

    @Comment("项目ID")
    @FormField(title = "所属项目", sortNum = "3", grid = true, type = InputType.select)
    private Long projectId;

    @Comment("父任务ID")
    @FormField(title = "父任务", sortNum = "4", grid = true, type = InputType.select)
    private Long parentTaskId;

    @Comment("任务描述")
    @FormField(title = "任务描述", sortNum = "5", type = InputType.textarea, col = 23)
    @Column(columnDefinition = "TEXT")
    private String description;

    @Comment("任务状态")
    @FormField(title = "任务状态", sortNum = "6", grid = true, type = InputType.select)
    @Column(length = 20)
    private String status; // TODO-待办, IN_PROGRESS-进行中, REVIEW-审核中, COMPLETED-已完成, CANCELLED-已取消

    @Comment("任务优先级")
    @FormField(title = "任务优先级", sortNum = "7", grid = true, type = InputType.select)
    @Column(length = 20)
    private String priority; // LOW-低, MEDIUM-中, HIGH-高, URGENT-紧急

    @Comment("任务类型")
    @FormField(title = "任务类型", sortNum = "8", grid = true, type = InputType.select)
    @Column(length = 20)
    private String type; // FEATURE-功能开发, BUG-缺陷修复, DOCUMENTATION-文档编写, TESTING-测试, OTHER-其他

    @Comment("负责人ID")
    @FormField(title = "负责人", sortNum = "9", grid = true, type = InputType.select)
    private Long assigneeId;

    @Comment("创建人ID")
    @FormField(title = "创建人", sortNum = "10", grid = true, type = InputType.select)
    private Long creatorId;

    @Comment("预计工时(小时)")
    @FormField(title = "预计工时(小时)", sortNum = "11", grid = true, type = InputType.el_input_number, sort = true)
    private Integer estimatedHours;

    @Comment("实际工时(小时)")
    @FormField(title = "实际工时(小时)", sortNum = "12", grid = true, type = InputType.el_input_number, sort = true)
    private Integer actualHours;

    @Comment("计划开始时间")
    @FormField(title = "计划开始时间", sortNum = "13", type = InputType.date, grid = true)
    private Date plannedStartDate;

    @Comment("计划结束时间")
    @FormField(title = "计划结束时间", sortNum = "14", type = InputType.date, grid = true)
    private Date plannedEndDate;

    @Comment("实际开始时间")
    @FormField(title = "实际开始时间", sortNum = "15", type = InputType.date, grid = true)
    private Date actualStartDate;

    @Comment("实际结束时间")
    @FormField(title = "实际结束时间", sortNum = "16", type = InputType.date, grid = true)
    private Date actualEndDate;

    @Comment("完成百分比")
    @FormField(title = "完成百分比", sortNum = "17", grid = true, type = InputType.el_input_number, sort = true)
    private Integer progress; // 0-100

    @Comment("任务标签")
    @FormField(title = "任务标签", sortNum = "18")
    @Column(length = 500)
    private String tags;

    @Comment("任务备注")
    @FormField(title = "任务备注", sortNum = "19", type = InputType.textarea, col = 23)
    @Column(columnDefinition = "TEXT")
    private String remarks;

    @Comment("任务附件")
    @FormField(title = "任务附件", sortNum = "20", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String attachments;
} 